<?php
// contact to database
$connect = mysql_connect("localhost", "root", "") or die ("Error , check your server connection.");
mysql_select_db("stms");
 
//Get data in local variable
$Regno=$_POST['Regno'];
$Title=$_POST['Title'];
$Firstname=$_POST['Firstname'];
$Lastname=$_POST['Lastname'];
$NICno=$_POST['NICno'];
$radio=$_POST['radio'];
$Civilstatus=$_POST['Civilstatus'];
$DOB=$_POST['DOB'];
$Nationality=$_POST['Nationality'];
$Religion=$_POST['Religion'];
$PermanentAddress=$_POST['Permanent Address'];
$TemporaryAddress=$_POST['Temporary Address'];
$Faculty=$_POST['Faculty'];
$CourseOfStudy=$_POST['CourseOfStudy'];
$Academicyear=$_POST['Academic year'];
$District=$_POST['District'];

$upd=mysql_query("UPDATE basicdetails SET Title='$Title',Firstname='$Firstname',Lastname='$Lastname',NICno='$NICno',Gender='$radio',Civilstatus='$Civilstatus',DOB='$DOB',Nationality='Nationality',Religion='$Religion',PermanentAddress='$PermanentAddress',TemporaryAddress='$TemporaryAddress',Faculty='$Faculty',CourseOfStudy='$CourseOfStudy',Academicyear='$Academicyear',District='$District' WHERE Regno='$Regno'");
if (mysql_affected_rows()==0){
$upd=mysql_query("insert into basicdetails(Regno,Title,Firstname,Lastname,NICno,Gender,Civilstatus,DOB,Nationality,Religion,PermanentAddress,TemporaryAddress,Faculty,CourseOfStudy,Academicyear,District) values('$Regno','$Title','$Firstname','$Lastname','$NICno','$radio','$Civilstatus','$DOB','$Nationality','$Religion','$PermanentAddress','$TemporaryAddress','$Faculty','$CourseOfStudy','$Academicyear','$District')");
}
//mysql_query($upd)  or die(mysql_error());
echo " successfully";